<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="user-scalable=no,width=device-width, initial-scale=1" id="viewport" name="viewport" initial-scale="1">

<script language="javascript" type="text/javascript" src="../js/js/baseJs.js"></script>

</head>
<body>

<div class="bank-list" id="bankList" style="display: none;">
    <div class="wap-header">申请业务
        <a class="back" onClick="javascript:window.history.back();return false;"></a>
    </div>
    <div class="bank-bd"> 
      <ul>
          <li v-for="item in projectItems"><a @click="applyProjectItem(item)"><span :class="getBankIcoClass(item.businessName)"></span>{{item.businessName}}</a> </li>
      </ul> 
      

    </div>
</div>
<script src="../js/js/rem_fix.js"></script>
<script src="../js/js/common.js"></script>
<script type="text/javascript">
   var token=getCookie("userToken");
   var userId=getCookie("userId");
   console.log(token)
   console.log(userId)
   var projectId=parseInt(window.location.hash.split("#")[1]) ;
   var loginUrl="../userBundle/login.mobile.html"+"?"+"../userBundle/bankList.mobile.html"+"#"+projectId;
   console.log(loginUrl)
   if(!token||!userId){
      window.location.href =loginUrl;
   }
  var bankListApp = new Vue({
      el: '#bankList', 
      data: {
         projectItems:'',
         telephone:'',
         isApplyProjectItem:false,
      },
      ready:function(){
        $("#bankList").show();
        var url="/project/getProjectItems ";
        var data={
                client: "1",
                id:projectId,
                token: token,
                userId: userId}
        pushData(url,data,function(res){
          console.log(res)
            if(res.state){
              this.projectItems=res.data.projectItems;
            }else if(res.errorCode==008){
               window.location.href =url;
            }
            else{
              // alert(res.message)
            }
        }.bind(this))
        var userData={client: "1",
                token: token,
                userId: userId
              }
        pushData("/user/getUserById",userData,function(res){
                if(res.state){
                   this.telephone=res.data.user.telephone;
                } else{
                  //alert(res.message)
                }   
        }.bind(this))

      }, 
      methods:{
        getBankIcoClass:function(key){
            var map = {
                工商银行信用卡: "icbc",
                农业银行信用卡: "abc",
                交通银行信用卡: "bcm",
                建设银行信用卡: "ccb",
                中国银行信用卡: "boc",
                招商银行信用卡: "cmb",
                兴业银行信用卡: "xyyh",
                广发银行信用卡: "gfyh",
                光大银行信用卡: "gdyh",
                民生银行信用卡: "msyh",
                华夏银行信用卡: "hxyh",
                平安银行信用卡: "payh",
                浦发银行信用卡: "pfyh",
                上海银行信用卡: "shyh",
            };
            return map[key]
        },
        applyProjectItem:function(item){
          if(this.isApplyProjectItem){
            return;
          }
          this.isApplyProjectItem=true;
          var url="/project/applyProjectItem";
          var data={
              address: "无",
              client: 1,
              doc: "信用卡申请",
              payAccount: "无",
              payType: null,
              projectId:projectId,
              projectItemId: item.id,
              telephone: this.telephone,
              token: token,
              userId: userId
            };

            pushData(url,data,function(res){
               if(res.state){
                 window.location.href=item.link;
               }else if(res.errorCode==008){
                  window.location.href =loginUrl;
               }
               else{
                alert(res.message);
               }
            }.bind(this));
        }
      }
    })
</script>

</body>
</html>